package 尚硅谷;

import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicStampedReference;

/**
 * @author zhangmin
 * @create 2022-03-22 20:56
 */
class User{
    String userName;
    int age;

    public User(String name, int age) {
        userName=name;
        age=age;
    }
}
public class AtomicReferenceDemo {
    public static void main(String[] args) {
        User z3=new User("z3",22);
        User li4=new User("li4",25);
        AtomicReference<User> atomicReference=new AtomicReference<>();
        atomicReference.set(z3);

        System.out.println(atomicReference.compareAndSet(z3,li4)+"\t"+atomicReference.get().toString());
        System.out.println(atomicReference.compareAndSet(z3,li4)+"\t"+atomicReference.get().toString());
    }
}
